const path = require("path");
const { BrowserWindow } = require("electron");

class CustomWindow extends BrowserWindow {
  constructor(config = {}, url) {
    const defaultConfig = {
      width: 960,
      height: 680,
      show: false,
      backgroundColor: "#efefef",
      webPreferences: {
        preload: path.resolve(__dirname, "../../preload.js"),
        devTools: true,
        nodeIntegration: true,
        contextIsolation: false,
      },
    };
    super({ ...defaultConfig, ...config });
    this.loadURL(url);
    this.once("ready-to-show", () => {
      this.show();
    });
  }
}

module.exports = CustomWindow;
